package modular {	import flash.system.ApplicationDomain;						
	/**	 * @author mich	 */	public class Library {		private static var inst:LibraryInstance;				internal static function getInstance():LibraryInstance {			if( inst == null ) inst = new LibraryInstance();			return inst;		}				public static function getClassOf( name:String, swf:String = null ):Class {			return getInstance().resolveClass( name, swf );		}				public static function register( l:ApplicationDomain, path:String ):void {			getInstance().register( l, path);		}
		
		public static function isLoaded(path:String):Boolean {			return getInstance().isLoaded( path );		}	}}
import flash.system.ApplicationDomain;
/** * @author mich */internal class LibraryInstance {	private var loaded:Object;		function LibraryInstance() {		loaded = new Object();	}	public function resolveClass( name:String, swf:String = null ):Class {		var _class:Class;				if( swf != "" ) {			try {				_class = ApplicationDomain( loaded[ swf ] ).getDefinition(name) as Class;			} catch( e:Error ) {				throw new Error( "could not find class: " + name + " in swf: " + swf );  			}				} else {			for each( var domain:ApplicationDomain in loaded ) {				try{				_class = domain.getDefinition(name) as Class;				} catch( e:Error ) { }			}			if( _class == null ) {				throw new Error( "could not find class: " + name + " in all loaded swfs" ); 			}		}		return _class;	}		public function register( l:ApplicationDomain, path:String ):void {		loaded[ path ] = l;	}		public function isLoaded(path:String):Boolean {		return loaded[ path ] != null;	}}